package homework;

/**
 * 遥控器类有重量，无线范围，颜色等属性
 * 有控制电视开机、关机、换台等功能
 */
public class Remote {
    private String color;
    private int scope;
    private double height;
    public void controlOpen(){
        System.out.println("遥控电视开机");
    }
    public void controlTurnOff(){
        System.out.println("遥控电视关机");
    }
    public void controlTransform(){
        System.out.println("遥控电视换台");
    }

    @Override
    public String toString() {
        return "这根遥控器颜色是"+color+"重量为"+height+"g,无线范围是"+scope+"米。";
    }

    public Remote(String color, int scope, double height) throws Exception {
        if (height<0){
            throw new Exception("重量非法");
        }
        if (scope<0){
            throw new Exception("接收范围非法");
        }
        this.color = color;
        this.scope = scope;
        this.height = height;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getScope() {
        return scope;
    }

    public void setScope(int scope) throws Exception {
        if (scope<0){
            throw new Exception("接收范围非法");
        }
        this.scope = scope;
    }

    public double getHeight() throws Exception {
        if (height<0){
            throw new Exception("重量非法");
        }
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }
}
